<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>检查字符的大小写</title>
</head>
<body>
<script>
    function checkCharType(charToCheck) {
        var returnValue = 'O';
        var charCode = charToCheck.charCodeAt(0);

        if (charCode >= 'A'.charCodeAt(0) && charCode <= 'Z'.charCodeAt(0)) {
            returnValue = 'U';
        } else if (charCode >= 'a'.charCodeAt(0) && charCode <= 'z'.charCodeAt(0)) {
            returnValue = 'L';
        } else if (charCode >= '0'.charCodeAt(0) && charCode <= '9'.charCodeAt(0)) {
            returnValue = 'N';
        }
        return returnValue;
    }

    var myString = prompt('Enter some text', 'Hello World!');
    switch (checkCharType(myString)) {
        case 'U':
            document.write('First character was upper case');
            break;
        case 'L':
            document.write('First character was lower case');
            break;
        case 'N':
            document.write('First character was number');
            break;
        default:
            document.write('First character was not a character or a number');
            break;
    }
</script>
</body>
</html>